import Vue from 'vue'
Vue.directive('focus', {
  inserted (el) {
    console.log(el)
    // console.log(el.tagName)
    // console.log(el.nodeName)
    if (['INPUT', 'TEXTAREA'].indexOf(el.tagName) !== -1) {
      el.focus()
    } else {
      let node = el.querySelector('input')
      if (node) {
        node.focus()
        return
      }
      node = el.querySelector('textarea')
      if (node) {
        node.focus()
        return
      }
      throw new Error('请把指令用在input 或者 textarea')
    }
  }

})
